package cmd

import (
	"context"
	_ "gf-vben-demo/driver"
	"gf-vben-demo/internal/middle"
	"gf-vben-demo/internal/router/system"
	"github.com/gogf/gf/v2/frame/g"
	"github.com/gogf/gf/v2/net/ghttp"
	"github.com/gogf/gf/v2/os/gcmd"
)

var (
	Main = gcmd.Command{
		Name:  "main",
		Usage: "main",
		Brief: "start http server",
		Func: func(ctx context.Context, parser *gcmd.Parser) (err error) {
			s := g.Server()
			s.Use(middle.MiddlewareHandlerResponse, ghttp.MiddlewareCORS)
			s.Group("/", func(group *ghttp.RouterGroup) {
				register(group)
			})
			s.Run()
			return nil
		},
	}
)

func register(group *ghttp.RouterGroup) {
	group.Group("/sys", func(group *ghttp.RouterGroup) {
		system.InitSysDictType(group) //字典
	})
}
